package main

import "Go-Exercise/immoc/tree"

type MyTreeNode struct {
	node *tree.Node
}

/**
	组合的方式扩展已有类型
 */
func (myNode *MyTreeNode) postOrder()  {
	if myNode == nil || myNode.node == nil {
		return
	}

	left := MyTreeNode{myNode.node.Left}
	left.postOrder()
	right := MyTreeNode{myNode.node.Right}
	right.postOrder()
	myNode.node.Print()

}

func main() {

	var root tree.Node
	root = tree.Node{Value: 3}
	root.Left = &tree.Node{}
	root.Right = &tree.Node{5, nil, nil}
	//new()直接返回地址
	root.Right.Left = new(tree.Node)
	root.Left.Right = tree.CreateNode(2)

	root.Right.Left.SetValue(4)

	//root.right.left.print()
	//fmt.Println()
	//
	//root.print()
	//root.setValue(100)
	//
	//var pRoot *treeNode
	//pRoot.setValue(200)
	//pRoot = &root
	//pRoot.setValue(300)
	//pRoot.print()

	root.Traverse()

	myRoot := MyTreeNode{&root}
	myRoot.postOrder()

}
